package guda.house.dal.dao.impl;

import guda.grape.autogen.common.BaseDAO;
import guda.house.dal.dao.ExtraFeeDAO;
import guda.house.dal.dataobject.ExtraFeeDO;
import guda.grape.autogen.common.page.BaseQuery;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ExtraFeeDAOImpl extends BaseDAO implements ExtraFeeDAO {

    @Override
	public Long insert(ExtraFeeDO extraFee) {
	      try {
                return (Long) getSqlMapperW().insert("extra_fee.insert",extraFee);
          } catch (Exception e) {
                throw new RuntimeException(e);
          }

	}

    @Override
	public ExtraFeeDO getExtraFeeById(Long feeId) {
	    return (ExtraFeeDO)getSqlMapClientTemplate().queryForObject("extra_fee.getExtraFeeById", feeId);
	}

    @Override
	public boolean delExtraFeeById(Long feeId) {
	    int num = 0;
        try {
            num = getSqlMapperW().delete("extra_fee.delExtraFeeById",feeId);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        if(num>0){
            return true;
        }else{
            return false;
        }
	}

    @Override
	public List<ExtraFeeDO> getExtraFeeByIds(List idsList) {
        Map m = new HashMap();
        m.put("idsList",idsList);
		return getSqlMapClientTemplate().queryForList("extra_fee.selectByIds", m);
	}

    @Override
	public void cleanAutoIncrement(Long feeId) {
	    try {
            getSqlMapperW().update("extra_fee.cleanAutoIncrement",feeId);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
	}

    @Override
    public List<ExtraFeeDO> selectForPage(BaseQuery baseQuery) {
        return getSqlMapClientTemplate().queryForList("extra_fee.selectForPage", baseQuery);
    }

    @Override
    public int countForPage(BaseQuery baseQuery) {
        return (Integer)getSqlMapClientTemplate().queryForObject("extra_fee.countForPage",baseQuery);
    }

    @Override
    public void updateByIdSelective(ExtraFeeDO extraFee) {
        try {
            getSqlMapperW().update("extra_fee.updateByIdSelective",extraFee);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public Long statBill(List<Long> suitIdList, String gmtDate, Long feeTypeId) {
        Map m = new HashMap();
        m.put("suitIdList",suitIdList);
        m.put("gmtDate",gmtDate);
        m.put("feeTypeId",feeTypeId);
        return (Long)getSqlMapClientTemplate().queryForObject("extra_fee.statBill", m);
    }

}

